LMAsJudge reward
LMAsJudge
Bases: ProgramAsJudge
Evaluate the output of a program using a LanguageModel.
Example:
async def main():
# ... program definition
program.compile(
reward=synalinks.rewards.LMAsJudge(
language_model=language_model,
# Optional: let the judge grade on a 1..5 integer scale
# instead of the default 0.0..1.0 `Score`. The reward
# is normalized back to 0.0..1.0 automatically.
score_type=synalinks.Rating,
)
optimizer=synalinks.optimizers.RandomFewShot(),
)
history = await program.fit(...)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_model
|
LanguageModel
|
The language model to use. |
None
|
prompt_template
|
str
|
The default jinja2 prompt template
to use (see |
None
|
instructions
|
list
|
The default instructions to use (see |
None
|
examples
|
list
|
The default examples to use in the prompt
(see |
None
|
score_type
|
type | str
|
Optional. The scale the judge picks the reward
from: |
None
|
name
|
str
|
Optional. string name of the reward instance. |
'lm_as_judge'
|
in_mask
|
list
|
Optional. list of keys to keep to compute the reward. |
None
|
out_mask
|
list
|
Optional. list of keys to remove to compute the reward. |
None
|
in_mask_pattern
|
str
|
Optional. Regex pattern; fields whose names match
are kept (combined with |
None
|
out_mask_pattern
|
str
|
Optional. Regex pattern; fields whose names match
are dropped (combined with |
None
|
Source code in synalinks/src/rewards/lm_as_judge.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
LMAsJudgeProgram
Bases: Program
Evaluate the output of a program using a LanguageModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_model
|
LanguageModel
|
The language model to use. |
None
|
prompt_template
|
str
|
The default jinja2 prompt template
to use (see |
None
|
examples
|
list
|
The default examples to use in the prompt
(see |
None
|
instructions
|
list
|
The default instructions to use (see |
None
|
score_type
|
type | str
|
Optional. The scale the judge picks the reward
from (see |
None
|
name
|
str
|
Optional. The name of the program. |
None
|
description
|
str
|
Optional. The description of the program. |
None
|
trainable
|
bool
|
Whether the program's variables should be trainable. |
True
|
Source code in synalinks/src/rewards/lm_as_judge.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |